import java.util.Scanner;

/**
 * Created with Interllij IDEA.
 * Descriptiption:
 * User: 王澄慧
 * Date: 2022-03-27
 * Time: 19:38
 */
public class ThirdDemo {
    public static void fun6(int n) {
        for (int i = 0; i < 32; i += 2) {
            System.out.print(((n >> i) & 1)+" ");
        }
        System.out.println();
        for (int i = 1; i < 32; i += 2) {
            System.out.print(((n >> i) & 1)+" ");
        }
    }

    public static void main11(String[] args) {
        fun6(9);
    }
    public static boolean fun5(int n){
        if((n & (n-1))==0){
            return true;
        }
        return false;
    }

    public static void main10(String[] args) {
        System.out.println(fun5(16));
    }
    public static int fun4(int n){
        int count = 0;
        while (n != 0){
            n = n&(n-1);
            count++;
        }
        return count;
    }

    public static void main9(String[] args) {
        System.out.println(fun4(17));
    }
    public static int fun3(int n){
        int count = 0;
        if((n & 1)!=0){
            count++;
        }
        n = n>>>1;
        return count;
    }

    public static void main8(String[] args) {
        System.out.println(fun3(17));
    }
    public static int fun2(int n) {
        int count = 0;
        for (int i = 0; i <32; i++) {
            if(((n >> i) & 1) != 0) {
                count++;
           }
        }
        return count;
    }
    public static void main7(String[] args) {
        System.out.println(fun2(13));
    }
    public static void fun1(){
        for (int i = 1; i <= 999_999 ; i++) {
            int tem = i;
            int conut = 0;
            while (tem != 0){
                conut++;
                tem /= 10;
            }
            tem = i;
            int sum = 0;
            while ((tem != 0)){
                sum += Math.pow(tem % 10,conut);
                tem /= 10;
            }
            if(sum == i){
                System.out.println(i);
            }
        }
        }

    public static void main6(String[] args) {
        fun1();
    }
    public static int fun(int a,int b){
        int i = a%b;
        while (i != 0){
            a = b;//15
            b = i;//25/15=10
            i = a%b;//
        }
        return b;
    }

    public static void main5(String[] args) {
        System.out.println(fun(15, 25));
    }
    public static void san(){
        for (int i = 1; i <= 9 ; i++) {
            for (int j = 1; j <= i ; j++) {
                System.out.print(j+"*"+i+"="+j*i+" ");
            }
            System.out.println();
        }
    }

    public static void main4(String[] args) {
        san();
    }
    public static boolean Year(int i){
        if(i%100 == 0 && i%400 == 0 || i%4 == 0){
            return true;
        }
        return false;
    }

   public static void main3(String[] args) {
        for (int j = 1000; j <= 2000 ; j++) {
            if(Year(j)){
                System.out.println(j);
            }
        }
    }
    public static boolean arr(int i) {
            for (int j = 2; j < Math.sqrt(i); j++) { //小于根号
                if (i % j == 0) {
                    return false;
                }
            }
            return true;
        }
    public static void main2(String[] args) {
        for (int a = 2; a < 100 ; a++) {
            if(arr(a))
            {
                System.out.println(a);
            }
        }
    }
    public static boolean arr1(int i) {
        for (int j = 2; j < i/2; j++) { //小于一半
            if (i % j == 0) {
                System.out.println("不是素数！");
                return false;
            }
        }
        System.out.println("这是一个素数");
        return true;
    }

    public static void main1(String[] args) {
        boolean r = arr(27);
        boolean c = arr1(31);
        System.out.println(r);
        System.out.println(c);
    }
}